<#assign base = request.contextPath />
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base id="base" href="${base}">
    <title>Edit Account </title>
</head>
<body>
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading text-center">
            <h1>Edit Account </h1>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" id="form" action="/account/update/${account.ac_code}" method="post"
                  role="form">
                <div class="form-group">
                    <label for="ac_code" class="col-sm-2 control-label">Code</label>
                    <div class="col-sm-10">
                        <input type="number" class="form-control" id="ac_code" name="ac_code" placeholder="Code"
                               value="${account.ac_code}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="ac_name" class="col-sm-2 control-label">Name</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="ac_name" name="ac_name" placeholder="Name"
                               value="${account.ac_name}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="ac_remark" class="col-sm-2 control-label">Remark</label>
                    <div class="col-sm-10">
                        <textarea class="form-control" id="ac_remark" name="ac_remark"
                                  placeholder="Remark">${account.ac_remark!"空"}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="ac_state" class="col-sm-2 control-label">State</label>
                    <div class="col-sm-10">
                        <label class="radio-inline">
                        <#if account.ac_state==1>
                            <input type="radio" name="ac_state" id="ac_state" checked="true" value="1"> 在线
                        <#else>
                            <input type="radio" name="ac_state" id="ac_state" value="1"> 在线
                        </#if>
                        </label>
                        <label class="radio-inline">
                        <#if account.ac_state==2>
                            <input type="radio" name="ac_state" id="ac_state" checked="true" value="2"> 离线
                        <#else>
                            <input type="radio" name="ac_state" id="ac_state" value="2"> 离线
                        </#if>
                        </label>
                        <#--<label class="radio-inline">-->
                        <#--<#if account.ac_state==3>-->
                            <#--<input type="radio" name="ac_state" id="ac_state" checked="true" value="3"> 封停-->
                        <#--<#else>-->
                            <#--<input type="radio" name="ac_state" id="ac_state" value="3"> 封停-->
                        <#--</#if>-->
                        <#--</label>-->
                    </div>
                </div>

                <div class="form-group">
                    <label for="ac_remark" class="col-sm-2 control-label">C&L Time</label>
                    <div class="col-sm-4">
                        <input type="text" id="ac_time" class="form-control">
                        <input type="text" id="ac_createtime" name="ac_createtime" style="display: none">
                        <input type="text" id="ac_logintime" name="ac_logintime" style="display: none">
                    </div>
                </div>

                <div class="form-group">
                    <label for="ac_type" class="col-sm-2 control-label">Type</label>
                    <div class="col-sm-10">
                        <select class="btn btn-default dropdown-toggle" name="ac_type">
                            <optgroup label="角色管理">
                            <#if account.ac_type==1>
                                <option value="1" name="ac_type" selected="true">用户</option>
                            <#else>
                                <option value="1" name="ac_type">用户</option>
                            </#if>
                            <#if account.ac_type==2>
                                <option value="2" name="ac_type" selected="true">游客</option>
                            <#else>
                                <option value="2" name="ac_type">游客</option>
                            </#if>
                            </optgroup>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-default">Submit</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="all" href="${base}/css/daterangepicker.css" />
<link href="${base}/css/select2.min.css" rel="stylesheet"/>
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${base}/js/moment.js"></script>
<script type="text/javascript" src="${base}/js/daterangepicker.js"></script>

<script src="${base}/js/select2.min.js"></script>
<script src="${base}/js/i18n/zh-CN.js"></script>
<script type="text/javascript">
    createtime="${account.ac_createtime}";
    logintime="${account.ac_logintime}";
//    alert(createtime)
//    alert(formatData(createtime))
    $(document).ready(function () {
        $(".btn btn-default dropdown-toggle").select2();
    });
    $('#ac_time').daterangepicker({
        timePicker: true,
        timePicker24Hour: true,
        startDate: formatData(createtime),
        endDate: formatData(logintime),
        locale:{
            applyLabel: '确认',
            cancelLabel: '取消',
            daysOfWeek:["日","一","二","三","四","五","六"],
            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
        }
    }, function (start, end, label) {
        createtime=start.format('YYYY-MM-DD HH:mm:ss');
        logintime=end.format('YYYY-MM-DD HH:mm:ss');
//        alert('A date range was chosen: ' + start.format('YYYY-MM-DD HH:mm:ss') + ' to ' + end.format('YYYY-MM-DD HH:mm:ss'));
    });

    $('#form').submit(function () {
        var folder = $("#ac_code").val();
        var folder2 = $("#ac_name").val();
        var folder3 = $("#ac_remark").val();
        var time = $("#ac_time").val();
        var folder4 = document.getElementsByName("ac_state");

        if ($.trim(folder) == "") {
            alert("please input Code!");
            return false;
        }
        if ($.trim(folder2) == "") {
            alert("please input Name!");
            return false;
        }
        var j = 0;

        for (var i = 0; i < folder4.length; i++) {
            if (folder4[i].checked == false) {
                j++;
//                alert(j)
            }
        }
        if (j == 3) {
            alert("please select State!");
            return false;
        }

//        var times = time.split("-");
        //alert(createtime);
//        time[0]="3/8/2017";
//        var create = times[0].split("/")
//        var login = times[1].split("/")
//
        $("#ac_createtime").val(createtime);
        $("#ac_logintime").val(logintime);
//        return true;
    });
function formatData(strData) {
    var data = strData.split(" ")[0].trim();
    var year = data.split("-")[0].trim();
    var month = data.split("-")[1].trim();
    var day = data.split("-")[2].trim();
    return month+"/"+day+"/"+year;
}
</script>
</html>